﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.SolveCranks.CCoSCSolveCranksCmdEnabler
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections.ObjectModel;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.SolveCranks;

public class CCoSCSolveCranksCmdEnabler : ITxCommandEnabler
{
  private bool ShouldEnable()
  {
    if (!this.isDataLoaded() || TxApplication.ActiveSelection.TotalCount < 1)
      return false;
    foreach (ITxObject allItem in (Collection<ITxObject>) TxApplication.ActiveSelection.GetAllItems())
    {
      if (allItem is ITxKinematicsModellable && CApSCSolveCranksApp.IsSupported(allItem as ITxKinematicsModellable) || CApSCSolveCranksApp.ContainsSupportedObjects(allItem))
        return true;
    }
    return false;
  }

  private bool isDataLoaded()
  {
    return TxApplication.ActiveDocument.PlatformGlobalServicesProvider.IsDataLoaded();
  }

  public bool Enable => this.ShouldEnable();
}
